<template>
  <div class='icons'>
    <swiper>
      <swiper-slide v-for="(page, index) in pages" :key="index">
        <div class="icon" v-for="(item, index) in page" :key="index">
          <div class='icon-image'>
            <img class="icon-img-content" :src="item.imgUrl" lt="">
          </div>
          <p class="icon-desc">{{item.desc}}</p>
        </div>
      </swiper-slide>
    </swiper>
  </div>
</template>
<script>
export default {
  props: {
    list: Array
  },
  data() {
    return {

    };
  },
  computed: {
    pages: {
      get() {
        let pages = [];
        this.list.forEach((item, index) => {
          const page = Math.floor(index / 8);
          if (!pages[page]) {
            pages[page] = [];
          }
          pages[page].push(item);
        });
        return pages;
      }
    }
  }
};
</script>

<style lang='stylus'scoped>
@import '~styles/varibles.styl';
@import '~styles/mixins.styl';

.icons >>> .swiper-container {
  height: 0;
  padding-bottom: 50%;
}

.icons {
  margin-top: 0.1rem;

  .icon {
    float: left;
    position: relative;
    height: 0;
    padding-bottom: 25%;
    width: 25%;

    p {
      position: absolute;
      text-align: center;
      bottom: 0;
      text-align: center;
      right: 0;
      left: 0;
      line-height: 0.44rem;
      height: 0.44rem;
      color: $darkTextColor;
      ellipsis();
    }

    .icon-image {
      position: absolute;
      top: 0px;
      left: 0px;
      right: 0px;
      bottom: 0.44rem;
      padding: 0.1rem;

      img {
        display: block;
        margin: 0 auto;
        height: 100%;
      }
    }
  }
}
</style>
